package com.yoomiito.app.widget.dialog;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;

import com.yoomiito.app.R;
import com.yoomiito.app.utils.NetworkUtils;

public class NoNetDialog extends BaseDialog {

    public NoNetDialog(@NonNull Context context) {
        this(context,0);
    }

    public NoNetDialog(@NonNull Context context, int themeResId) {
        super(context, R.style.dialog);
    }

    protected NoNetDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    public View setView() {
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_net_error,null);
        view.findViewById(R.id.dialog_net_btn)
                .setOnClickListener(v -> {
                    NetworkUtils.startSetNet(mContext);
                    dismiss();
                });
        setCanceledOnTouchOutside(true);
        return view;
    }

    @Override
    public void dismiss() {
        mContext = null;
        super.dismiss();
    }
}
